package com.gaogzhen.intro.commonMethod;

/**
 * @author Administrator
 * @version 1.0
 * @description yield priority
 * @date 2022-10-03 09:47
 */
public class CMYieldPriority {
    public static void main(String[] args) {
        Runnable r1 = () -> {
           int count = 0;
           for (;;) {
               System.out.println("=====>1 " + count++);
           }
        };

        Runnable r2 = () -> {
            int count = 0;
            for (;;) {
//                Thread.yield();
                System.out.println("=====>2 " + count++);
            }
        };

        Thread t1 = new Thread(r1, "t1");
        Thread t2 = new Thread(r2, "t2");
        t1.setPriority(Thread.MIN_PRIORITY);
        t2.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        t2.start();
    }
}
